package com.xyoto.community.controller;

import com.xyoto.community.aspect.annotation.RequiresLogin;
import com.xyoto.community.dto.CheckContentDTO;
import com.xyoto.community.dto.DeletePictureDTO;
import com.xyoto.community.dto.UploadPictureDTO;
import com.xyoto.community.service.PictureService;
import com.xyoto.community.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 统一图片上传接口
 */
@RestController
@Api(tags = "统一图片接口")
@RequestMapping("/picture")
public class PictureController {

    @Autowired
    private PictureService pictureService;

    @RequiresLogin
    @ApiOperation("统一图片上传接口")
    @PostMapping("/upload")
    public Result uploadPicture(UploadPictureDTO uploadPictureDTO){
        return pictureService.uploadPicture(uploadPictureDTO);
    }

    @RequiresLogin
    @ApiOperation("图片删除接口")
    @DeleteMapping("/delete")
    public Result deletePicture(@Valid @RequestBody DeletePictureDTO deletePictureDTO){
        return pictureService.deletePicture(deletePictureDTO);
    }

    @ApiOperation("统一文本校验接口")
    @PostMapping("/checkContent")
    public Result checkContent(@Validated CheckContentDTO checkContentDTO){
        return pictureService.checkContent(checkContentDTO);
    }

}
